Ext.define('StaffServer.controller.MenuController', {
	extend : 'Ext.app.Controller',
	views : [ 'index.West', 'index.Center' ],// 声明该控制层要用到的view
	config : {},
	refs : [ {
		ref : 'west',
		selector : 'west'
	}, {
		ref : 'center',
		selector : 'center'
	} ],
	init : function() {
		var me = this;
		me.control({
			'west' : {
				itemclick : me.onWestItemclick
			}
		});
	},
	onWestItemclick : function(view, record, item, index, event, eventOpts) {
		var me = this;
		if (record.data.value) {
			var controller = me.application.loadController(record.data.value);
			var tabId=record.data.value + 'viewtab';
			var xtype =controller.tabView;
			var center=me.getCenter(),
			comp=me.getCenter().getComponent(tabId);
//			debugger;
			// 如果tabPanel已经打开了某个item，再次点击菜单时则激活它,否则新建
			if (typeof comp == 'undefined') { 
				comp = center.add({
					id:tabId,
					xtype : xtype,
					iconCls:record.data.iconCls,
					closable:true
				});
			}
		
			center.setActiveTab(comp);
			console.log(comp);
			
		}
	}
});
